package com.zhiche.lisa.bms.service.statistics.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zhiche.lisa.bms.dao.mapper.statistics.StaticIncomeCostMapper;
import com.zhiche.lisa.bms.dao.model.statistics.StaticIncomeCost;
import com.zhiche.lisa.bms.service.statistics.StaticIncomeCostService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 应收费用统计表 服务实现类
 * </p>
 *
 * @author liangpeng
 * @since 2019-01-18
 */
@Service
public class StaticIncomeCostServiceImpl extends ServiceImpl<StaticIncomeCostMapper, StaticIncomeCost> implements StaticIncomeCostService {


    /**
     * 得到应收的其他费用
     *
     * @return
     */
    @Override
    public List<StaticIncomeCost> getIncomeOtherCostByCostType(String costType,String orderId) {
        EntityWrapper<StaticIncomeCost> ew = new EntityWrapper<>();
        ew.eq("sys_order_id",orderId);
        ew.ne("cost_type",costType);
        return baseMapper.getIncomeCostByCostType(ew);
    }

    /**
     * 得到未处理的订单
     *
     * @return
     */
    @Override
    public List<StaticIncomeCost> getDistinctOrderNoDeal(int intCount) {
        List<StaticIncomeCost> list = baseMapper.getDistinctNoDealOrder();
        if(intCount > 0){
            return list.stream().limit(intCount).collect(Collectors.toList());
        }

        return list;
    }
}
